public class Test {
    public static void main(String[] args) {
        BinaryTree tree = new BinaryTree();
        //创建一颗二叉树
        BinaryTree.TreeNode root = tree.createTree();
        //前序遍历并打印
        System.out.print("前序遍历：");
        tree.preOrder(root);
        System.out.println();
        //中序遍历并打印
        System.out.print("中序遍历：");
        tree.inOrder(root);
        System.out.println();
        //后序遍历并打印
        System.out.print("后序遍历：");
        tree.lastOrder(root);
        System.out.println();
        //实例化队列
        MyQueue myQueue = new MyQueue();
        //入队操作
        myQueue.offer(12);
        myQueue.offer(16);
        myQueue.offer(19);
        myQueue.offer(22);
        myQueue.offer(7);
        myQueue.offer(2);
        //出队操作,出3个元素
        System.out.print("出队的元素为：");
        for (int i = 0; i < 3; i++) {
            System.out.print(myQueue.poll()+" ");
        }
        System.out.println();
        //拿到剩余元素的队顶元素
        System.out.print("队顶元素是：");
        System.out.println(myQueue.peek());
    }
}
